﻿@model BillForMVC.Models.BillCategoryViewModel

@{
    ViewData["Title"] = "Index";
}

<h1>Index</h1>

<p>
    <a asp-action="Create">Create New</a>
</p>

<form asp-controller="Bills" asp-action="Index" method="get">
    <select asp-for="BillCategory" asp-items="Model.Categories">
        <option value="">All</option>
    </select>
    <p>
        内容：<input type="text" name="SearchString"/>
        <input type="submit" value="Filter"/>
    </p>
</form>
<table class="table">
    <thead>
        <tr>
            <th>
                @Html.DisplayNameFor(model => model.Bills[0].Content)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Bills[0].BillDate)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Bills[0].Price)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Bills[0].Category)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Bills[0].User)
            </th>
            <th></th>
        </tr>
    </thead>
    <tbody>
@foreach (var item in Model.Bills) {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.Content)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.BillDate)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Price)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Category)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.User)
            </td>
            <td>
                <a asp-action="Edit" asp-route-id="@item.Id">Edit</a> |
                <a asp-action="Details" asp-route-id="@item.Id">Details</a> |
                <a asp-action="Delete" asp-route-id="@item.Id">Delete</a>
            </td>
        </tr>
}
    </tbody>
</table>
